<template>
  <div class="n-list">
    <slot name="header"></slot>
    <div class="n-list-items">
      <NListItem v-for="(item, index) in dataSource" :key="item.id || index">
        <template #content>
          <slot name="renderItem" :item="item" :index="index">
            <!-- 默认内容 -->
            <div class="n-list-item-default">
              {{ item.title || '默认标题' }}
              <div class="n-list-item-meta">{{ item.description || item.time || '' }}</div>
            </div>
          </slot>
        </template>
      </NListItem>
    </div>
    <slot name="footer"></slot>
  </div>
</template>

<script setup>
defineProps({
  dataSource: {
    type: Array,
    required: true
  },
  size: {
    type: String,
    default: 'default',
    validator: (val) => ['small', 'default', 'large'].includes(val)
  },
  loading: {
    type: Boolean,
    default: false
  },
  split: {
    type: Boolean,
    default: true
  }
})
</script>

<style scoped>
.n-list {
  font-size: 14px;
  line-height: 1.5715;
  box-sizing: border-box;
}

.n-list-items {
  margin: 0;
  padding: 0;
  list-style: none;
}

.n-list-item-default {
  padding: 12px 0;
}

.n-list-item-meta {
  font-size: 12px;
  color: rgba(0, 0, 0, 0.45);
  margin-top: 4px;
}
</style>
